//
//  ViewController.swift
//  ios-python
//
//  Created by mac on 2024/12/11.
//

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        self.view.addSubview(btn)
    }

    lazy var btn: UIButton = {
        let button = UIButton(type: .system)
        button.setTitle("Click Me", for: .normal)
        button.frame = CGRect(x: 100, y: 100, width: 200, height: 50)
        button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)
        return button
    }()
    
    @objc func buttonTapped() {
        
        let args1: [Any] = ["World"]
        if let result1 = PythonManager.runPythonScript("test_init", withMethod: "greet", andArgs: args1) as? String {
            print(result1)
        } else {
            print("Failed to get result for greet")
        }

        let args2: [Int] = [2, 3]
        if let result2 = PythonManager.runPythonScript("test_init", withMethod: "add", andArgs: args2) as? Int {
            print(result2)
        } else {
            print("Failed to get result for add")
        }


    }
}

